# -*- coding: utf-8 -*-
import scrapy
from scrapy.http.response.html import HtmlResponse
from scrapyBook.items import ScrapybookItem
# import json
class BookdetailSpider(scrapy.Spider):
    name = 'Bookdetail'
    allowed_domains = ['amazon.com']  # 允许的域名
    start_urls = ['https://www.amazon.com/dp/B0787GLL3W']
    # start_urls = ['http://amazon.com/']

    def parse(self, response):
        print('====================' + '80')
        # user_agent = json.loads(response.text)['user-agent']
        name = response.xpath('//*[@id="productTitle"]//text()').get().strip()
        # getall()  是获取的list
        # content = "".join(content).strip()
        # BookItem

        book = 'fdf'
        item = ScrapybookItem(name=name, book=book)
        yield item
        print('====================' + '9ii')
        #  设置重复的链接可以请求多次
        # yield scrapy.Request('url',dont_filter=True)
